//深拷贝
class Money implements Cloneable{
    public double num = 12.9;

    @Override
    protected Object clone() throws CloneNotSupportedException {
        return super.clone();
    }
}
class Person implements Cloneable{
    public int id;
    Money money = new Money();
    public Person(int id) {
        this.id = id;
    }

    @Override
    protected Object clone() throws CloneNotSupportedException {
        Person tmp = (Person) super.clone();
        tmp.money = (Money) this.money.clone();
        return tmp;
    }

    @Override
    public String toString() {
        return "Person{" +
                "id=" + id +
                '}';
    }
}

public class Test {
    public static void main(String[] args) throws CloneNotSupportedException {
        Person person1 = new Person(100);
        Person person2 = (Person) person1.clone();
        System.out.println("person1:"+person1);
        System.out.println("person2:"+person2);
        person1.money.num = 354;
        System.out.println("person1:"+person1.money.num);
        System.out.println("person2:"+person2.money.num);

    }
}
